From 5b03cf175a40a52034612245b288352019d79843 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sat, 23 Apr 2016 10:21:13 +0100 Subject: [PATCH] gl: Use the appropriate format on GLES When uploading a Cairo image surface to a GL texture we cannot use GL_BGRA and GL_UNSIGNED_INT_8_8_8_8_REV on OpenGL ES, as they do not exist in the core spec. --- gdk/gdkglcontext.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c index 8eb39f1197..ca29955848 100644 --- a/gdk/gdkglcontext.c +++ b/gdk/gdkglcontext.c @@ -248,12 +248,20 @@ gdk_gl_context_upload_texture (GdkGLContext *context, /* GL_UNPACK_ROW_LENGTH is available on desktop GL, OpenGL ES >= 3.0, or if * the GL_EXT_unpack_subimage extension for OpenGL ES 2.0 is available */ - if (epoxy_is_desktop_gl () || priv->gl_version >= 30 || priv->has_unpack_subimage) + if (!gdk_gl_context_get_use_es (context) || + (gdk_gl_context_get_use_es (context) && + (priv->gl_version >= 30 || priv->has_unpack_subimage))) { glPixelStorei (GL_UNPACK_ALIGNMENT, 4); glPixelStorei (GL_UNPACK_ROW_LENGTH, cairo_image_surface_get_stride (image_surface) / 4); - glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, - cairo_image_surface_get_data (image_surface)); + + if (gdk_gl_context_get_use_es (context)) + glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, + cairo_image_surface_get_data (image_surface)); + else + glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, + cairo_image_surface_get_data (image_surface)); + glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); } else -- 2.30.2